package com.ymttest.database.sqlwapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.YmtCommissionDetail;
import com.ymttest.utils.EnvSetup;

/************************************************************************************
 * @File name :DefaultWapper.java
 * @Author : zhouyi
 * @Date : 2015年6月1日
 * @Copyright : 洋码头
 ************************************************************************************/
public class YmtCommissionDetailWapper {
	static SqlManager manage;

	public YmtCommissionDetailWapper() {
		if (manage == null || manage.getEnv() != "ymt" + EnvSetup.getEnv()
				|| manage.isClosed()) {
			manage = new SqlManager("ymt" + EnvSetup.getEnv());
		}
	}

	/**
	 * 使用 accountid 查询信息
	 * 
	 * @param i
	 * @return {dCreateTime=2016-01-26 10:33:57.263, dUpdateTime=2016-01-26
	 *         10:33:57.263, fAvailAmount=0.00, iAction=0, iCurrencyType=1,
	 *         iUserId=20000000, iAccountType=0, Version=0, fRewardAmount=0.00,
	 *         fFreezeAmount=0.00, sAccountInfoId=00010020000000, sMemo=自动化测试专用}
	 * @throws InterruptedException
	 */
	public List<YmtCommissionDetail> selectByOrderId(long orderId)
			throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<YmtCommissionDetail> pia = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtCommissionDetailMapper.selectByOrderId",
						orderId);
		return pia;
	}

	/**
	 * 
	 * @param m
	 * @optional queryCount 查询记录数<br>
	 * @optional joinCondition 连表查询<br>
	 * @optional queryCondition 查询条件<br>
	 * @return
	 * @throws InterruptedException
	 */
	public List<YmtCommissionDetail> selectCommissionDetail(Map m)
			throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<YmtCommissionDetail> pia = manage
				.getSelectResults(
						"com.ymttest.database.mapping.YmtCommissionDetailMapper.selectCommissionDetail",
						m);
		return pia;
	}

	/**
	 * 关闭数据库连接
	 */
	public void close() {
		manage.close();
	}

	@Override
	protected void finalize() throws Throwable {
		this.close();
		manage = null;
		super.finalize();
	}

	public static void main(String args[]) {
		try {
			/*
			 * List<YmtAccountEntry> list = new
			 * AccountDefaultWapper().selectAccountEntry
			 * ("00010020000000","68e67232-0a86-4d8c-889d-0c78a54c0b8e"); for
			 * (YmtAccountEntry ya : list) { Logger.debug(ya.getAccountid()); }
			 */

			// List<YmtAccountEntry> m=new
			// AccountDefaultWapper().selectAccountEntry(355976173,"f7a44e0ae1464e3391e46e67e608cfd5",0);
			// List<Map> m=new
			// AccountDefaultWapper().selectAccountInfoByUserId(20000002,0);
			Map m = new HashMap();
			m.put("UserId", "21000002");
			m.put("BeginTime", "2016-01-28 18:05:26.237");
			m.put("EndTime", "2016-01-29 22:05:26.237");
			m.put("AccountingType", 1);

			m.put("limit", 20);

			List<YmtCommissionDetail> rm = new YmtCommissionDetailWapper()
					.selectByOrderId(112444862);
			Logger.debug(rm);

		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
